package com.jemmyee.core.plugin.email;

import junit.framework.TestSuite;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

/**
 * @Description:邮件发送测试
 * @author:jemmyee@gmail.com
 * @date:2010-10-28
 * @version:v1.0
 */
public class SimpleMailTest extends TestSuite{
	private static JavaMailSender mailSender;
	private static SimpleMailMessage simpleMailMessage;
	private static String to="exceljava@163.com";
	
//	private final static String confs[] = new String[] {
//			"WebRoot/WEB-INF/conf/core/spring/spring-mail.xml",
//	};
	private final static String confs[] = new String[] {
			"com/baihong/core/config/spring/spring-mail.xml"
	};
	
	public static void main(String[] args) {
		ApplicationContext act=new ClassPathXmlApplicationContext(confs);
		mailSender=(JavaMailSender)act.getBean("mailSender");
		simpleMailMessage=(SimpleMailMessage)act.getBean("simpleMailMessage");
		System.out.println("mail send start...");
		SimpleMail simpleMail=new SimpleMail(mailSender, simpleMailMessage);
		String subject="临时侦系统";
		String content="临侦系统正式上线运行";
		simpleMail.sendOneMail(subject,content,to);
        System.out.println("mail send ok!"); 
	}
	
//	public void setup() {
//		ApplicationContext act=new ClassPathXmlApplicationContext(confs);
//		mailSender=(JavaMailSender)act.getBean("mailSender");
//		simpleMailMessage=(SimpleMailMessage)act.getBean("simpleMailMessage");
//	}
//	
//	public void testSend(){
//		System.out.println("mail send start...");
//		SimpleMail simpleMail=new SimpleMail(mailSender, simpleMailMessage);
//		simpleMail.sendOneMail(to, "测试成功");
//        System.out.println("mail send ok!"); 
//	}

}
